package com.ys.service.sys.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.bo.util.HttpUtil;
import com.ys.service.sys.UtilService;
import com.ys.vo.R;

@Service("utilService")
public class UtilServiceImpl implements UtilService {

	@Override
	public R getHypeText(Integer type, Long id) {
		
		if (type == null) {
			return R.error("类型不存在");
		}
		
		if (id == null) {
			return R.error("ID不能为空");
		}

		String content = null;
		
		GetHypeTextDto dto = new GetHypeTextDto(content);
		
		return R.ok(dto);
	}

	@Override
	public String getImgNewByOld(String urlOld) {
		String url = "https://cdntest.mini-ease.com/common/uploadImgByUrl";
		
		Map<String, String> param = new HashMap<String, String>();
		param.put("urlOld", urlOld);
		String result = HttpUtil.sendPost(url, param, "utf-8");
//		logger.info(result);
		System.out.println("result---" + result);
		JSONObject resultJO = JSON.parseObject(result);
		
		String urlNew = null;
		if (resultJO.getInteger("code") == 0) {
			urlNew = resultJO.getJSONObject("data").getString("urlNew");
		}
		return urlNew;
	}
}
